package cn.fczds.camhelper.complaint.controller;

import cn.fczds.camhelper.base.response.JsonResult;
import cn.fczds.camhelper.complaint.pojo.dto.ComplaintQuery;
import cn.fczds.camhelper.complaint.pojo.dto.ComplaintSaveParam;
import cn.fczds.camhelper.complaint.pojo.vo.ComplaintVO;
import cn.fczds.camhelper.complaint.service.ComplaintService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("v1/complaint")
public class ComplaintController {
    @Autowired
    ComplaintService complaintService;

    @GetMapping("select")
    public JsonResult selectByAdminId(ComplaintQuery complaintQuery){
        log.debug("complaintQuery={}",complaintQuery);
        List<ComplaintVO> list=complaintService.selectByAdminId(complaintQuery);
        log.debug("投诉列表:list={}",list);
        return JsonResult.ok(list);
    }

    @PostMapping("add")
    public JsonResult addComplaint(ComplaintSaveParam complaintSaveParam){
        log.debug("complaintSaveParam={}",complaintSaveParam);
        complaintService.add(complaintSaveParam);
        return JsonResult.ok();
    }

    @PostMapping("update")
    public JsonResult updateComplaintStatus(@PathVariable Long complaintId){
        log.debug("当前审核的投诉单：complaintId={}",complaintId);
        complaintService.updateComplaintStatus(complaintId);
        return JsonResult.ok();
    }
}
